﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

using System.Collections;
using System.Web.Security;

using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Configuration;

using System.Text;
using MySql.Data;
using MySql.Data.MySqlClient;


namespace ES_Project.Pages
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        MySqlCommand objCmd = new MySqlCommand(); 
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private void clear()
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
            
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string StrConn = WebConfigurationManager.ConnectionStrings["baseessystem"].ToString();

            MySqlConnection Conn = new MySqlConnection(StrConn);
            string strSQL;
            strSQL = "INSERT INTO family_mast (family_code,family_name)   VALUES ('" + this.TextBox1.Text + "','" + this.TextBox2.Text + "')";
            //Conn.ConnectionString = strSQL;
            //Conn.Open();
            //objCmd.Connection = Conn;
            //objCmd.CommandText = strSQL;
            //objCmd.CommandType = CommandType.Text;

            //SqlCommand cmd = new SqlCommand();
            MySqlDataAdapter da4 = new MySqlDataAdapter(strSQL, Conn);
            Conn.Open();
            objCmd.Connection = Conn;
            objCmd.CommandType = CommandType.Text;
            objCmd.CommandText = strSQL;

            objCmd.ExecuteNonQuery();

            Response.Write("<script>alert('บันทึกข้อมูลเรียบร้อยแล้วค่ะ')</script>");
            clear();
        }
    }
}